// composables/useLogin.ts
import { ref, reactive, onMounted, type Ref } from 'vue'
import { useRouter } from 'vue-router'
import authService from '@/auth/auth.service'
// const restoreChoices = (data) => {
//   const restored = {}
//   for (const key in data) {
//     if (data.hasOwnProperty(key)) {
//       // 将二维数组转为 [{ value, label }] 格式
//       restored[key] = data[key].map(([value, label]) => ({ value, label }))
//     }
//   }
//   return restored
// }

export function useHome() {
  const choicesData = ref({})

  const getChoices = async () => {
    try {
      const data = await authService.fetchChoices()
      choicesData.value = data
    } catch (error) {
      // 可以在这里添加更多的错误处理逻辑
      console.error('Failed to get choices:', error)
    }
  }

  onMounted(() => {
    getChoices()
  })

  return {
    choicesData,
  }
}
